package com.appleyk.config2;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;

/**
 * <p>越努力，越幸运</p>
 *
 * @author appleyk
 * @version V.0.1.1
 * @blob https://blog.csdn.net/appleyk
 * @date created on  7:31 下午 2020/12/2
 */
@Component
@Data
@Validated // 属性类上必须加这个注解，开启验证，不加的话，不会对属性字段的值进行校验
@ConfigurationProperties(prefix = "spring.validate")
public class ValidateProperties {

    String userName;
    @NotBlank(message = "密码不能为空！")
    @Length(min = 6,max = 20,message = "密码长度[6,20]")
    String password;
    @Email
    String email;

}
